/*
 *    Copyright (C) 2011-2012 Hai Bison
 *
 *    See the file LICENSE at the root directory of this project for copying
 *    permission.
 */

package group.pals.mailgate.objects;

import java.util.Comparator;

/**
 *
 * @author Hai Bison
 */
public class StringObjectComparator implements Comparator<Object> {

    public int compare(Object o1, Object o2) {
        if (o1 == null && o2 == null) {
            return 0;
        }
        if (o1 == null) {
            return -1;
        }
        if (o2 == null) {
            return 1;
        }
        return o1.toString().toLowerCase().compareTo(o2.toString().toLowerCase());
    }
}
